<template>
	<view>
		<Header title="客资管理" :backshow="true"></Header>
		<view class="toubu">
			<!-- 搜索开始 -->
			<view class="content_content" style="width: calc(100% - 12rpx);">
				<view class="index_header">
					<view class="">
						<view>
							<image src="/static/image/index/sousuo.png" @click="onKeyInput"></image>
							<input class="search_neirong" v-model="search" :disabled="shows" type="search"
								@confirm="onKeyInput" placeholder="搜索客户" placeholder-class="index_placeholder">
						</view>
					</view>
					<view class="img_sx" @click="shaixuans()">
						<image src="/static/image/index/shaixuan.png"></image>
					</view>
				</view>
			</view>
			<!-- 搜索结束 -->
			<!-- 导航栏 -->
			<view class="content_content nav_list">
				<view class="_list" @click="dianji(index,item.name)" v-for="(item,index) in nav" :key="index">
					<view :class="{hunsha_sy:index == di_index}">{{item.name}}
						<uni-badge class="jiaob" size="small" :text="item.num" absolute="rightTop"
							:offset="[-3, 5]"></uni-badge>
					</view>
					<image src="/static/image/index/xuanzhong.png" v-if="index == di_index" mode=""></image>
				</view>
			</view>
			<!--列表 -->
			<view class="content_content_con yinying" v-for="item in xinxival"
				@click="publics.navigateTo('/view/kehu/kehu_xiangqing?id='+item.id+'&tianjia='+tianjia+'&typeid='+typeids)">
				<view class="zhuangtai">
					<view>客资ID:{{item.id}}
						<image src="/static/image/me/fuzhi.png" @click.stop="publics.fuzhi(item.id)" class="fuzhi">
						</image>
					</view>
					<view>{{item.typename}}</view>
				</view>
				<view class="xinxi">
					<view class="xingming">姓名：{{item.kzname}}</view>
					<view>客户类型：{{item.servertype}}</view>
					<view class="dianhua">联系电话：{{item.tel}}</view>
					<view class="wechart">微信号：{{item.wechat}}</view>
					<view>预计婚期：{{item.wedding}}</view>
					<view class="chengshi">拍摄城市：
						<span style="padding-right:12rpx">{{publics.s_dizhi()}}</span>
					</view>
					<view class="zhuanrang" v-if="item.upusername!==''">转让人：{{item.upusername}}</view>
				</view>
			</view>


			<view class="grace-loading" v-if="xiala==0 && xinxival.length > 15">上拉加载更多~</view>
			<view class="grace-loading" v-if="xiala==1 && zanwu != 1">没有更多数据啦~</view>
			<zanwushuju v-if="xinxival.length==0 && zanwu==1"></zanwushuju>
		</view>

		<requestLoading></requestLoading>

		<kehusx :show="shows" @shaixuan="shaixuan" margin="calc(var(--status-bar-height) + 228rpx)"></kehusx>
		<!-- <Login></Login> -->
	</view>
</template>

<script>
	import kehusx from "@/components/kehusx.vue"
	export default {
		components: {
				kehusx
		},
		data() {
			return {
				zanwu: 1,
				value: 0,
				tishi: 1, //展示加载动画
				pagenum: 1,
				xiala: 999,
				hasmsg: false,
				search: '',
				shows: false,
				nav: [{
					name: "全部",
					num: ''
				}, {
					name: "已领取",
					num: ''
				}, {
					name: "活动锁单",
					num: ''
				}, {
					name: "订单成交",
					num: ''
				}, {
					name: "转让客资",
					num: ''
				}, {
					name: "放弃客资",
					num: ''
				}, {
					name: "取消订单申请",
					num: ''
				}, {
					name: "取消订单成功",
					num: ''
				}, {
					name: "取消订单失败",
					num: ''
				}, {
					name: "客资退回申请",
					num: ''
				}, {
					name: "客资退回成功",
					num: ''
				}, {
					name: "客资退回失败",
					num: ''
				}, {
					name: "取消活动锁单",
					num: ''
				}],
				xinxival: [],
				di_index: 0,
				typeid: 5,
				sift: "全部",
				maps: [],
				indexer: '',
				tianjia: 999,
				wantcity: '',
				//isShow:'全部', // 判断父组件的数据有没有这一项
				typeids: ''
			}
		},
		onShow: function() {
			// if(this.tishi ==1){
			this.liebiao()

			// } 
		},
		onPullDownRefresh() {
			this.tishi = 2;
			this.xiala = -1;
			this.pagenum = 1;
			this.liebiao()
			console.log("触发下拉刷新")
		},
		onReachBottom() {
			console.log("上拉加载")
			if (this.xiala === 0) {
				this.pagenum++;
				this.tishi = 1;
				this.sift;
				this.liebiao()
				// this.shaixuan()
			}
		},
		computed: {},
		// mounted() {
		// 	const timer = setInterval(() => {
		// 		if (this.value >= 199) {
		// 			clearInterval(timer)
		// 			return
		// 		}
		// 		this.value++
		// 	}, 100)
		// },
		methods: {
			liebiao() {
				var that = this;
				this.configure.ajax({
					url: 'kehu/yilingquKZ',
					tishi: that.tishi,
					data: {
						typeid: that.di_index,
						sift: that.sift,
						pagenum: that.pagenum,
						search: that.search
					},
					method: 'POST',
					success: function(res) {

						if (res.data.maps) {
							that.nav[0].num = res.data.maps[0]
							that.nav[1].num = res.data.maps[1]
							that.nav[2].num = res.data.maps[2]
							that.nav[3].num = res.data.maps[3]
							that.nav[4].num = res.data.maps[4]
							that.nav[5].num = res.data.maps[5]
							that.nav[6].num = res.data.maps[6]
							that.nav[7].num = res.data.maps[7]
							that.nav[8].num = res.data.maps[8]
							that.nav[9].num = res.data.maps[9]
							that.nav[10].num = res.data.maps[10]
							that.nav[11].num = res.data.maps[11]
							that.nav[12].num = res.data.maps[12]
						}
						if (res.data.resource == null || res.data.resource.length == 0) {
							if (that.pagenum == 1) {
								that.xinxival = []
							}
							that.xiala = 1;
							return;
						} else {
							that.xiala = 0;
							if (that.tishi === 2) {
								that.xinxival = res.data.resource
							} else {
								if (that.pagenum == 1) {
									that.xinxival = res.data.resource
								} else {
									that.xinxival = that.xinxival.concat(res.data.resource)
								}
							}
						}
						that.tishi = '1111'
						that.$forceUpdate();
					}
				})
			},
			shaixuan(e) {
				this.pagenum = 1;
				var that = this;
				if (e.states == 2) {
					this.configure.ajax({
						url: 'kehu/yilingquKZ',
						tishi: that.tishi,
						data: {
							typeid: that.typeid,
							sift: e.sxtype,
							pagenum: that.pagenum,
							search: that.search
						},
						method: 'POST',
						success: function(res) {
							that.sift = e.sxtype
							that.xinxival = res.data.resource
						}
					})
				}
				this.shows = false;
			},
			dianji(index, name) {
				this.di_index = index;
				this.sift = name;
				this.pagenum = 1;
				this.tishi = 1;
				this.xinxival = [];
				this.liebiao();
			},
			shaixuans() {
				this.shows = !this.shows;
			},
			onKeyInput: function() {
				var patt1 = new RegExp(/\s+/g); //正则验证空格
				// if (this.search == '') {
				// 	uni.showToast({
				// 		title: '请输入关键字',
				// 		icon: "none"
				// 	});
				// 	return false;
				// } else if (patt1.test(this.search)) {
				// 	uni.showToast({
				// 		title: '请输入关键字',
				// 		icon: "none"
				// 	});
				// 	return false;
				// }
				this.liebiao();
				this.xinxival = []
				// this.diyici = -1;
				console.log("1111111")
			},
		}
	}

</script>

<style lang="scss" scoped>
	.uni-badge {
		background-color: $zhuce_color !important;
	}

	.fuzhi {
		width: 24rpx;
		height: 24rpx;
		margin-left: 18rpx;
	}

	.grace-loading {
		text-align: center;
		color: $qianhui_ziti;
		font-size: 30rpx;
		margin-top: 40rpx;
		margin-bottom: 40rpx;
	}

	.xingming {
		word-break: break-all;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
		width: 208rpx;
	}

	.chengshi {
		width: 640rpx;
	}

	.img_sx {
		box-shadow: $shadow_zhuse;
	}

	.hunsha_sy {
		font-weight: bold;
		color: $heise_ziti !important;
		font-size: 34rpx;
	}

	.yinying {
		box-shadow: $shadow;
	}

	.nav_list {
		margin-top: 140rpx;
		display: flex;
		overflow: auto;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.nav_list::-webkit-scrollbar {
		display: none;
	}

	._list {
		position: relative;
		padding-left: 12rpx;

		view {
			font-size: 28rpx;
			margin-right: 20rpx;
			padding-bottom: 30rpx;
			padding-top: 10rpx;
			color: $qianhui_ziti ;
		}

		image {
			width: 30rpx;
			height: 8rpx;
			position: absolute;
			top: 64rpx;
			left: 12rpx;
		}
	}

	.zhuangtai {
		font-size: 26rpx;
		color: $heise_ziti;
		display: flex;
		justify-content: space-between;
		border-bottom: 2rpx solid var(--qianhui_eee);
		padding: 30rpx 0rpx 24rpx 0rpx;
	}

	.zhuangtai view:last-child {
		color: $heise_ziti;
		font-size: 26rpx;
		font-weight: bold;
	}

	.xinxi {
		font-size: 26rpx;
		color: $qianhuione_ziti;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		margin-bottom: 30rpx;

		view {
			padding: 24rpx 0 0 0rpx;
		}
	}

	.xinxi view:nth-child(2) {
		margin-left: 162rpx;
	}

	.wechart {
		// margin-left: 66rpx;
		word-break: break-all;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
		width: 235rpx;
	}

	.dianhua {
		width: 300rpx;
	}

</style>

